from pydantic import BaseModel, HttpUrl
from datetime import datetime
from typing import Optional

class URLBase(BaseModel):
    original_url: HttpUrl

class URLCreate(URLBase):
    expires_at: Optional[datetime] = None

class URLResponse(URLBase):
    id: int
    short_code: str
    created_at: datetime
    expires_at: Optional[datetime]
    owner_id: int

    class Config:
        from_attributes = True

class ClickCreate(BaseModel):
    url_id: int
    ip_address: str
    user_agent: str

class ClickResponse(ClickCreate):
    id: int
    clicked_at: datetime

    class Config:
        from_attributes = True 